package pkg

import (
	"github.com/dgrijalva/jwt-go"

	"time"
	"user-rpc/basic/config"
)

func GetJwtToken(userId string) (string, error) {
	claims := make(jwt.MapClaims)
	iat := time.Now().Unix()
	claims["exp"] = iat + 86400
	claims["iat"] = iat
	claims["userId"] = userId
	token := jwt.New(jwt.SigningMethodHS256)
	token.Claims = claims
	secretKey := config.AppConfig.GetJwtToken.SecretKey
	return token.SignedString([]byte(secretKey))
}
